import { Button } from 'antd';
import { Component } from 'react';
import pubSub from 'pubsub-js'

class App extends Component {
//  state = {num:1,total:3}
handleChangeCheck = (e) => {
  this.props.allCheck(e.target.checked)
}
componentDidMount() {
  pubSub.subscribe('add',(msg,data)=>{
    console.log(data,'data');
  })
}
 render() {
  const {todos} = this.props
  const hasDone = todos.filter(item => item.done).length
  const total = todos.length
 return (
    <div>
      <input type="checkbox" checked={hasDone===total} onChange={this.handleChangeCheck} />
      <span>已完成 {hasDone}/{total}</span>
      <Button type="primary">清空</Button>
    </div>
  );
}
 
}

export default App;
